

package com.mt.restaurant.controller.staff;

import org.springframework.security.access.prepost.PreAuthorize;
import com.mt.common.core.annotation.ApiPageParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.mt.common.core.web.base.PageDTO;
import com.mt.common.core.web.base.PageResultDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;



import com.mt.restaurant.dto.staff.RoleSalaryEditDto;
import com.mt.restaurant.entity.staff.RoleSalary;
import com.mt.restaurant.service.staff.RoleSalaryService;
									

@Api(tags = "角色薪资")
@RestController
@RequestMapping("/api/restaurant/staff/RoleSalary")
@CrossOrigin(allowCredentials = "true")
public class RoleSalaryController {
private static Logger logger = LoggerFactory.getLogger(RoleSalaryController.class);



																														@Autowired private RoleSalaryService roleSalaryService;
	
	/**
	* 根据分页参数查询角色薪资集合
	*
	* @param pageDTO 分页条件
	*/
	@PreAuthorize("hasAuthority('restaurant:staff:RoleSalary:view')")
	@ApiOperation("分页查询角色薪资")
	@ApiPageParam
	@PostMapping("/findRoleSalarys")
	public PageResultDTO findRoleSalarys(@RequestBody PageDTO pageDTO){
		return this.roleSalaryService.findRoleSalarys(pageDTO);
	}

	/**
	* 根据ID查询指定的角色薪资
	*
	* @param roleSalaryId Id
	*/
	@PreAuthorize("hasAuthority('restaurant:staff:RoleSalary:view')")
	@ApiOperation("根据id查询角色薪资")
	@ApiPageParam
	@PostMapping("/findRoleSalary")
	public RoleSalary findRoleSalary(@RequestParam Long roleSalaryId){
		return this.roleSalaryService.findRoleSalary(roleSalaryId);
	}

	/**
	* 根据ID查询指定的角色薪资(包含外键名称)
	*
	* @param roleSalaryId Id
	*/
	@PreAuthorize("hasAuthority('restaurant:staff:RoleSalary:view')")
	@ApiOperation("根据ID查询指定的角色薪资(包含外键名称)")
	@PostMapping("/findRoleSalaryForView")
	public RoleSalary findRoleSalaryForView(@RequestParam Long roleSalaryId){
		return this.roleSalaryService.findRoleSalaryWithForeignName(roleSalaryId);
	}

	/**
	* 根据ID查询指定的角色薪资(包含角色薪资和外键名称)
	*
	* @param roleSalaryId Id
	*/
	@PreAuthorize("hasAuthority('restaurant:staff:RoleSalary:view')")
	@ApiOperation("根据ID查询指定的角色薪资(包含角色薪资和外键名称)")
	@PostMapping("/findRoleSalaryForEdit")
	public RoleSalaryEditDto findRoleSalaryForEdit(@RequestParam Long roleSalaryId){
				RoleSalaryEditDto roleSalaryEditDto = new RoleSalaryEditDto();
		roleSalaryEditDto.setRoleSalary(this.roleSalaryService.findRoleSalaryWithForeignName(roleSalaryId));

		this.prepareRoleSalaryEditDto(roleSalaryEditDto);

		return roleSalaryEditDto;
	}

	/**
	* 根据ID查询指定的角色薪资(只提取ID 和 Name)
	*
	* @param roleSalaryId Id
	*/
	@PreAuthorize("hasAuthority('restaurant:staff:RoleSalary:view')")
	@ApiOperation("根据ID查询指定的角色薪资(只提取ID 和 Name)")
	@PostMapping("/findRoleSalarysWithIdNameById")
	public RoleSalary findRoleSalarysWithIdNameById(@RequestParam Long roleSalaryId){
	return this.roleSalaryService.findRoleSalarysWithIdNameById(roleSalaryId);
	}

	/**
	* 根据名称查询角色薪资集合(只提取ID 和 Name)
	*
	* @param roleSalaryName 名称
	*/
	@PreAuthorize("hasAuthority('restaurant:staff:RoleSalary:view')")
	@ApiOperation("根据名称查询角色薪资集合(只提取ID 和 Name)")
	@PostMapping("/findRoleSalarysWithIdNameByName")
	public List<RoleSalary> findRoleSalarysWithIdNameByName(@RequestParam String roleSalaryName){
	return this.roleSalaryService.findRoleSalarysWithIdNameByName(roleSalaryName);
	}


	/**
	* 创建新的角色薪资
	*
	*/
	@PreAuthorize("hasAuthority('restaurant:staff:RoleSalary:add')")
	@ApiOperation("创建新的角色薪资")
	@PostMapping("/createRoleSalary")
	public RoleSalaryEditDto createRoleSalary(){
				RoleSalaryEditDto roleSalaryEditDto = new RoleSalaryEditDto();
		roleSalaryEditDto.setRoleSalary(new RoleSalary());

		this.prepareRoleSalaryEditDto(roleSalaryEditDto);
		return roleSalaryEditDto;
	}

	private void prepareRoleSalaryEditDto(RoleSalaryEditDto roleSalaryEditDto){
																													}

	/**
	* 新增保存角色薪资
	*
	* @param roleSalary 实体对象
	*/
	@PreAuthorize("hasAuthority('restaurant:staff:RoleSalary:add')")
	@ApiOperation("新增保存角色薪资")
	@PostMapping("/saveRoleSalary")
	public RoleSalary saveRoleSalary(@RequestBody RoleSalary roleSalary){
		return this.roleSalaryService.saveRoleSalary(roleSalary);
	}

	/**
	* 修改保存角色薪资
	*
	* @param roleSalary 实体对象
	*/
	@PreAuthorize("hasAuthority('restaurant:staff:RoleSalary:update')")
	@ApiOperation("修改保存角色薪资")
	@PostMapping("/updateRoleSalary")
	public RoleSalary updateRoleSalary(@RequestBody RoleSalary roleSalary){
		return this.roleSalaryService.updateRoleSalary(roleSalary);
	}

	/**
	* 根据ID删除角色薪资
	*
	* @param roleSalaryId ID
	*/
	@PreAuthorize("hasAuthority('restaurant:staff:RoleSalary:remove')")
	@ApiOperation("根据ID删除角色薪资")
	@PostMapping("/deleteRoleSalary")
	public void deleteRoleSalary(@RequestParam Long roleSalaryId){
		this.roleSalaryService.deleteRoleSalary(roleSalaryId);
	}



}

